package com.qf.im.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.im.entity.Friendship;
import com.qf.im.entity.User;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 好友关系表(Friendship)表数据库访问层
 *
 * @author makejava
 * @since 2023-10-31 10:26:05
 */
public interface FriendshipDao extends BaseMapper<Friendship> {

    @Select("""
        select u.id, u.username, u.header, if(fs.beizhu = "", u.nickname, fs.beizhu) as nickname 
            from `friendship` fs join `user` u on fs.fid = u.id
            where uid = #{uid} and fs.status = 0
    """)
    List<User> queryMyFriends(Integer uid);
}

